package com.jied.duodian.web.qt;

import com.jied.duodian.entity.Dutity.Dupaixu;
import com.jied.duodian.entity.Dutity.Page;
import com.jied.duodian.service.Impl.DdProductServiceImpl;
import com.jied.duodian.util.CommonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Description:
 *
 * @author LiJie
 * @date Created on 2020/10/29
 * WWW https://github.com/j6l
 */
@RestController
@RequestMapping("/qtproduct")
@Slf4j
public class QTProductController {

    @Autowired
    DdProductServiceImpl ddProductService;

    /**
     * 查询排序页面数据
     *
     * @param dupaixu
     * @param page
     * @return
     */
    @PostMapping("/gethuowu/{page}")
    public CommonResult updataByIdProduct(
            @RequestBody Dupaixu dupaixu,
            @PathVariable("page") Integer page) {
        log.info( "排序查询第{}页,Dupaixu详情{}", page, dupaixu );
        // if (dupaixu.getSproduct() == null || dupaixu.getSproduct().length() < 2) {
        //     return CommonResult.failed();
        // }
        if (dupaixu.getLei() == null) dupaixu.setLei( "0" );
        if (dupaixu.getBrandname() == null) dupaixu.setBrandname( "0" );
        Page page1 = ddProductService.getpaixu( dupaixu, page );
        return CommonResult.success( page1 );
    }

}
